<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script>
        $(function(){
            $("input[type='button']").click(function(){
               $.ajax({
                   type:'post',
                   url:'/user/register',
                   data:$("#registerForm").serialize(),
                   dataType:"json",
                   success:function(result){
                       if(result.responseCode == "1001"){
                           location.href = "/showLogin";
                       }else{
                           $("#errorMsg").html(result.message);
                       }
                   }
               })
            });
        });
    </script>
</head>
<body>
<h1>用户注册</h1>
<a href="/showLogin">返回登录</a>
<hr>
<form id="registerForm">
    用户名:<input type="text" name="username"><br>
    密&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"><br>
    电&nbsp;&nbsp;&nbsp;话:<input type="text" name="phone"><br>
    地&nbsp;&nbsp;&nbsp;址:<input type="text" name="address"><br>
    <input type="button" value="注册">
    <span style="color:red;" id="errorMsg"></span>
</form>
</body>
</html>